# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo10.12
# Description:
# Author:       $赵怡蕾
# Date:         2019/3/7
#-------------------------------------------------------------------------------

nestedList = [[1,2,3],[4,3,2],[1,2,4,5,7]]
# 生成器函数
def enumList(nestedList):
    # 对二维的列表进行迭代
    for subList in nestedList:
        # 二维列表中每一个元素是一个一维的列表，所以需要对一维的列表进行迭代
        for element in subList:
            # 通过yield语句返回当前生成的值
            yield element
# 对生成器函数进行迭代
for num in enumList(nestedList):
    print(num,end=' ')
print()
# 将生成器函数转换为列表
numList = list(enumList(nestedList))
print(numList)
print(numList[1:4])